package com.example.demo.impl;

import org.jim.common.ImAio;
import org.jim.common.ImPacket;
import org.jim.common.packets.Command;
import org.jim.common.packets.RespBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.bean.Result;
import com.example.demo.entity.es.Msg;
import com.example.demo.exception.SPIPException;
import com.example.demo.intf.WsInterface;

@RestController
public class WsImpl implements WsInterface {

	@Override
	public Result sendToUser(Msg msg) throws SPIPException {
		ImPacket chatPacket = new ImPacket(Command.COMMAND_CHAT_REQ,
				new RespBody(Command.COMMAND_CHAT_REQ, msg).toByte());
		ImAio.sendToUser(msg.getTo(), chatPacket);
		return Result.getOk();
	}

}
